package Main;
import java.io.File;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Main {

	private Shell sShell = null;
	private Label label1;
	private TabItem tabItem2;
	private TabItem tabItem3;
	private TabItem tabItem1;
	private TabFolder tabFolder1;
	private Button button2;
	private Label label3;
	private Text text3;
	private Label label2;
	private Button button1;
	private Text text2;
	private Text text1;
	private Image bg;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		/* Before this is run, be sure to set up the launch configuration (Arguments->VM Arguments)
		 * for the correct SWT library path in order to run with the SWT dlls. 
		 * The dlls are located in the SWT plugin jar.  
		 * For example, on Windows the Eclipse SWT 3.1 plugin jar is:
		 *       installation_directory\plugins\org.eclipse.swt.win32_3.1.0.jar
		 */
		Display display = Display.getDefault();
		Main thisClass = new Main();
		thisClass.createSShell();
		thisClass.sShell.open();

		while (!thisClass.sShell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

	/**
	 * This method initializes sShell
	 */
	private void createSShell() {
		File f = new File("");
		String go=new String(f.getAbsolutePath());
		bg=new Image(Display.getDefault(),go+"/image.jpg");
		Image close=new Image(Display.getDefault(),go+"/cl.gif");
		sShell = new Shell(Display.getDefault(),0);
		sShell.setText("Shell");
		sShell.setBackgroundImage(bg);
		int height=Display.getDefault().getBounds().height;
		System.out.println(height);
		int width=Display.getDefault().getBounds().width;
		System.out.println(width);
		//sShell.setBounds(200,200, 640, 480);
		sShell.setSize(new Point(640, 480));
		sShell.setLayout(null);
		{
			text1 = new Text(sShell, SWT.BORDER);
			text1.setBounds(319, 18, 257, 25);
		}
		{
			text2 = new Text(sShell, SWT.BORDER);
			text2.setBounds(319, 58, 257, 25);
		}
		{
			button1 = new Button(sShell, SWT.PUSH | SWT.CENTER | SWT.BORDER);
			button1.setText("Open XML");
			button1.setBounds(26, 20, 71, 25);
			button1.addSelectionListener(new SelectionAdapter() {
				public void widgetSelected(SelectionEvent evt) {
					button1WidgetSelected(evt);
				}
			});
		}
		{
			label1 = new Label(sShell, SWT.VERTICAL | SWT.CENTER | SWT.BORDER);
			label1.setBounds(245, 18, 72, 31);
			label1.setText("Current Path");
		}
		{
			label2 = new Label(sShell, SWT.CENTER | SWT.BORDER);
			label2.setText("Relative Expression");
			label2.setBounds(246, 58, 72, 31);
		}
		{
			text3 = new Text(sShell, SWT.BORDER);
			text3.setBounds(319, 98, 257, 25);
		}
		{
			label3 = new Label(sShell, SWT.CENTER | SWT.BORDER);
			label3.setText("Name / Value");
			label3.setBounds(246, 98, 72, 31);
		}
		{
			button2 = new Button(sShell,SWT.BORDER);
			button2.setBounds(595, 4, 25, 20);
			button2.setImage(close);
			button2.addSelectionListener(new SelectionAdapter() {
				public void widgetSelected(SelectionEvent evt) {
					sShell.dispose();
				}
			});
		}
		{
			tabFolder1 = new TabFolder(sShell, SWT.NONE|SWT.V_SCROLL);
			{
				tabItem1 = new TabItem(tabFolder1, SWT.NONE);
				tabItem1.setText("Current Node List");
			}
			{
				tabItem2 = new TabItem(tabFolder1,SWT.NONE);
				tabItem2.setText("Elements");
			}
			{
				tabItem3 = new TabItem(tabFolder1, SWT.NONE);
				tabItem3.setText("Attributes");
			}
			tabFolder1.setBounds(2, 324, 214, 150);
			tabFolder1.setSelection(0);
		}
	}
	
	private void button1WidgetSelected(SelectionEvent evt) {
		FileDialog fd=new FileDialog(sShell, SWT.OPEN);
		fd.setFilterExtensions(new String[]{"*.xml"});
		String selected=fd.open();
		System.out.println(selected);
		
	}

}
